package sng.modules.controller
{
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	import org.puremvc.as3.patterns.observer.Notification;
	
	import sng.modules.model.LoginProxy;
	import sng.modules.model.vo.LoginVO;
	import sng.modules.system.NameSpace;
	import sng.modules.view.ApplicationMediator;
	import sng.modules.view.LoginMediator;

	/**
	 * 
	 * @author leonliu
	 * 
	 */	
	public class LoginCommand extends SimpleCommand 
	{
		public function LoginCommand()
		{
		}
		
		override public function execute(notification:INotification):void
		{
			
		
			switch (notification.getName()){
				case NameSpace.FacadeStart:
				{
					facade.registerProxy(new LoginProxy());
					
					var app:Main=notification.getBody() as Main;
					facade.registerMediator(new ApplicationMediator(app));
					facade.registerMediator(new LoginMediator(app));
					break;
				}
				case NameSpace.ApplicationLogin:
				{
					var loginVO:LoginVO = notification.getBody() as LoginVO;
					//从facade中获取proxy
					var loginProxy:LoginProxy = facade.retrieveProxy(NameSpace.LoginProxyName) as LoginProxy;
					loginProxy.CheckLogin(loginVO);	
				}
				
				default:
					break;
			}
		
		}

	}
}